package com;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;


public class Aspectj {

    public void myBefore(JoinPoint joinPoint){
        System.out.println("------------");
        System.out.println("这是前置通知:日志开始打印..");
        System.out.println("目标类是:"+joinPoint.getTarget());
        System.out.println("目标类方法是:"+joinPoint.getSignature().getName());
    }
    public void myAfterReturn(JoinPoint joinPoint){
        System.out.println("------------");
        System.out.println("这是后置通知:日志开始打印..");
        System.out.println("目标类是:"+joinPoint.getTarget());
        System.out.println("目标类方法是:"+joinPoint.getSignature().getName());
    }
    public void afterThrowing(Exception e){
        System.out.println("--------------");
        System.out.println("异常通知类型是"+e.getMessage());
        System.out.println("--------------");
    }
    public void after(){
        System.out.println("------------");
        System.out.println("这是最终通知:日志开始打印..");
    }
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("------------");
        System.out.println("这是环绕通知前置:日志开始打印..");
        Object proceed = joinPoint.proceed();
        System.out.println("这是环绕通知后置:日志开始打印..");
        return proceed;
    }
}
